<template>
  <div>
    <b>填写备注</b>
    <ul class="type01">
      <li
        :class="{ active: postData.type === '01' }"
        @click="postData.type = '01'"
      >
        已通知面试
      </li>
      <li
        :class="{ active: postData.type === '02' }"
        @click="postData.type = '02'"
      >
        已找到工作
      </li>
      <li
        :class="{ active: postData.type === '03' }"
        @click="postData.type = '03'"
      >
        不适合
      </li>
      <li
        :class="{ active: postData.type === '00' }"
        @click="postData.type = '00'"
      >
        其他
      </li>
    </ul>
    <p v-if="postData.type === '00'">
      <van-field
        v-model="postData.content"
        rows="5"
        autosize
        type="textarea"
        maxlength="20"
        show-word-limit
        placeholder="选择“其他”时的备注内容"
        class="text"
      />
    </p>
    <p>
      <van-button
        round
        type="primary"
        text="取消"
        class="btn"
        @click="onCancle"
      ></van-button>
      <van-button
        round
        type="primary"
        text="保存"
        class="btn"
        :loading="loading_submit"
        :disabled="disable_submit"
        @click="onSubmit"
      ></van-button>
    </p>
  </div>
</template>

<script>
import { Button, Field } from "vant";
import {
  CompanyResumeAddResumeRemark,
  CompanyResumeGetResumeRemark,
} from "@/util/http";
import Global from "@/Global";
export default {
  name: "ResumeRemark",
  components: {
    [Button.name]: Button,
    [Field.name]: Field,
  },
  props: ["resumeid"],
  created() {
    this.postData.resumeid = this.resumeid;
    CompanyResumeGetResumeRemark(this.resumeid).then((res) => {
      //   console.log(res);
      if (res != null) {
        this.postData.type = res.MarkType;
        this.postData.content = res.MarkContent;
      }
    });
  },
  computed: {
    disable_submit() {
      if (
        this.postData.type != "00" ||
        (this.postData.type === "00" && this.postData.content.trim().length > 0)
      )
        return false;
      return true;
    },
  },
  // 定义属性
  data() {
    return {
      postData: {
        resumeid: "",
        type: "01",
        content: "",
      },
      loading_submit: false,
    };
  },
  // 方法集合
  methods: {
    onCancle() {
      this.$bus.$emit(Global.bus_company_resume_showinfo_update, 0);
    },
    onSubmit() {
      if (this.postData.type === "01") {
        this.postData.content = "已通知面试";
      } else if (this.postData.type === "02") {
        this.postData.content = "已找到工作";
      } else if (this.postData.type === "03") {
        this.postData.content = "不适合";
      }
      this.loading_submit = true;
      CompanyResumeAddResumeRemark(this.postData).then((res) => {
        // console.log(res);
        this.loading_submit = false;
        this.$bus.$emit(Global.bus_company_resume_showinfo_update, res.result);
      });
    },
  },
};
</script>

<style scoped></style>
